﻿@model PetaPoco.Page<Shop.Order.Models.Order>
@{
    Layout = null;
}
<div style="margin-bottom:5px">
    <input type="button" class="btn btn btn-primary" value="导出本页" onclick="Down(@Model.CurrentPage)" />
</div>
<table class="table table-bordered table-hover table-condensed">
    @if (Model.Items.Count == 0)
            {
        <tr>
            <td colspan="13">暂无数据</td>
        </tr>
    }
    else
    {
        foreach (var item in Model.Items)
        {

            <tr>
                <td colspan="5" class="warning">订单号:@item.OrderNumber</td>
                @*<td colspan="4">快递单号:@item.CourierNumber</td>
                <td colspan="4">身份证号:@item.IDCard</td>*@
            </tr>
            @Html.Action("_OrderDetail", "Order",new { OrderNumber = item.OrderNumber })

            
        }
    }
</table>
<div class="btn-toolbar" role="toolbar">
    @if (Model.TotalPages <= 1)
            {
        <div class="btn-group" role="group">
            <input type="button" class="btn btn-default disabled" value="首页" onclick="" />
            <input type="button" class="btn btn-default disabled" value="上一页" onclick="" />
            <input type="button" class="btn btn-default disabled" value="下一页" onclick="" />
            <input type="button" class="btn btn-default disabled" value="尾页" onclick="" />
        </div>
    }
    else if (Model.CurrentPage == 1 && Model.TotalPages != 1)
    {
        <div class="btn-group" role="group">
            <input type="button" class="btn btn-default disabled" value="首页" onclick="" />
            <input type="button" class="btn btn-default disabled" value="上一页" onclick="" />
            <input type="button" class="btn btn-default" value="下一页" onclick="NextPage()" />
            <input type="button" class="btn btn-default " value="尾页" onclick="Shadowe()" />
        </div>
    }
    else if (Model.CurrentPage > 1 && Model.CurrentPage < Model.TotalPages)
    {
        <div class="btn-group" role="group">
            <input type="button" class="btn btn-default" value="首页" onclick="HomePage()" />
            <input type="button" class="btn btn-default" value="上一页" onclick="PreviousPage()" />
            <input type="button" class="btn btn-default" value="下一页" onclick="NextPage()" />
            <input type="button" class="btn btn-default " value="尾页" onclick="Shadowe()" />
        </div>
    }
    else if (Model.CurrentPage == Model.TotalPages && Model.CurrentPage != 1)
    {
        <div class="btn-group" role="group">
            <input type="button" class="btn btn-default" value="首页" onclick="HomePage()" />
            <input type="button" class="btn btn-default" value="上一页" onclick="PreviousPage()" />
            <input type="button" class="btn btn-default disabled" value="下一页" onclick="" />
            <input type="button" class="btn btn-default disabled" value="尾页" onclick="" />
        </div>
    }
    <a class="btn btn-default">第@(Model.CurrentPage)页/共@(Model.TotalPages)页</a>

    <div class="col-lg-2">
        <div class="input-group">
            <input type="text" class="form-control" placeholder="输入页码" id="pagenum">
            <span class="input-group-btn">
                <button class="btn btn-default" type="button" id="GO" onclick="GoPage()">Go!</button>
            </span>
        </div>
    </div>
</div>

<script type="text/javascript">
     //首页
    function HomePage() {
        JumpPage("1");
    }
    //下一页
    function NextPage()
    {
        JumpPage("@(Model.CurrentPage+1)");
    }
    //上一页
    function PreviousPage()
    {
        JumpPage("@(Model.CurrentPage-1)");
    }
    //尾页
    function Shadowe()
    {
        JumpPage("@(Model.TotalPages)");
    }
    //跳转到页数
    function GoPage()
    {
        var page = $("#pagenum").val();
        if (page == "") {
            alert("请输入跳转的页数");
        }
        else if (page < 1) {
            alert("请输入正确的页数");
        }
        else if (page >@(Model.TotalPages))
        {
            alert("输入不能超过总页数");
        }
        else
        {
            JumpPage(page)
        }
    }
</script>